/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/
#if !defined(AFX_FIELDMAP_H__B34CE4AF_6201_4B06_8CE4_8E59CD241795__INCLUDED_)
#define AFX_FIELDMAP_H__B34CE4AF_6201_4B06_8CE4_8E59CD241795__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Field.h"
#include "STLMatrix.h"

namespace contour
{

/*! \brief A 2D field object based on matrices.

\ingroup FieldGroup

*/
template<class T>
class TFieldMap : public TField<T>  
{
public:
	typedef std::TSTLMatrix<T> Matrix;

	//! \name Constructors
	//@{
	TFieldMap(const std::TSTLMatrix<T>& vData = std::TSTLMatrix<T>(0,0)):m_mMap(vData){};
	virtual ~TFieldMap(){};
	//@}

	//! \name Data handling
	//@{
	//! returns the number of rows
	size_t GetRowSize() const							{	return m_mMap.nrows();};
	//! returns the number of columns
	size_t GetColSize() const							{	return m_mMap.ncols();};
	//! return the value at m[yi,xi]
	T GetVal(size_t xi, size_t yi) const				{	return m_mMap(xi,yi);};
	//! Sets the data
	void SetMap(const std::TSTLMatrix<T>& vData)	{	m_mMap = vData;};
	//! returns const reference to the matrix
	const Matrix& GetMap() const					{	return m_mMap;};
	//! returns reference to the matrix
	Matrix& GetMap()								{	return m_mMap;};
	//@}

	//! \name Virtual functions
	//@{	
	virtual T Eval(T x, T y)
	{
		return 0;
	};
private:
	std::TSTLMatrix<T> m_mMap;
};

};
#endif // !defined(AFX_FIELDMAP_H__B34CE4AF_6201_4B06_8CE4_8E59CD241795__INCLUDED_)
